Ví dụ Grunt (phần mềm)

Đây là một ví dụ về một Gruntfile được viết để cho thấy làm thế nào có thể tải plugin, tạo nhiệm vụ và cấu hình chúng:

module.exports = function(grunt) {  // Task configuration  grunt.initConfig({    taskName1: 'Task1 Configuration',    taskName2: 'Task2 Configuration'  });  // Loads plugins  grunt.loadNpmTasks('pluginName1');  grunt.loadNpmTasks('pluginName2');  // Custom tasks  grunt.registerTask('customTaskName1', 'Custom task description', function(taskParameter) {    // Custom statements  });  // Combining multiple tasks to a single task  grunt.registerTask('customTaskName2', ['taskName1,customTaskName1']);  // Default task - runs if task name is not specified  grunt.registerTask('default', ['customTaskName2']);};

Trong ví dụ trên, thực hiện lệnh grunt sẽ chạy <customtaskName2> , lệnh này đã được xác định như là một sự kết hợp của <taskName1><customTaskName1>.

Liên quan